package org.taskexecution.taskexecution.application.scheduledTask.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cephr.accountcenter.application.scheduledTask.TaskExecutionLogService;
import com.cephr.accountcenter.infrastructure.presistent.mapper.scheduledTask.TaskExecutionLogMapper;
import com.cephr.accountcenter.infrastructure.presistent.po.scheduledTask.TaskExecutionLog;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lydond
 * @description: 任务日志服务实现
 * @create_date: 2025/10/20-15:24
 */
@Service
public class TaskExecutionLogServiceImpl extends ServiceImpl<TaskExecutionLogMapper, TaskExecutionLog> implements TaskExecutionLogService {
    @Override
    public List<TaskExecutionLog> getBySchdulesId(Long scheduleId) {
        LambdaQueryWrapper<TaskExecutionLog> wq = new LambdaQueryWrapper<>();
        wq.select(
                TaskExecutionLog::getLogId,
                TaskExecutionLog::getScheduleId,
                TaskExecutionLog::getTaskDefId,
                TaskExecutionLog::getStartTime,
                TaskExecutionLog::getEndTime,
                TaskExecutionLog::getDurationMs,
                TaskExecutionLog::getIsSuccess,
                TaskExecutionLog::getRetryCount,
                TaskExecutionLog::getExecutorAddress,
                TaskExecutionLog::getCreatedAt
        ).eq(TaskExecutionLog::getScheduleId, scheduleId);
        return this.list(wq);
    }
}

